\ProvidesPackage{beamerthemeALUF}[2014/03/26]

\definecolor{JOrange}{RGB}{249,142,42}
\definecolor{ALUFred}{RGB}{185,0,36}
\definecolor{ALUFblue}{RGB}{8,63,146}
\definecolor{ALUFwhite}{RGB}{255,255,255}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Outer theme
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\useoutertheme[width=.15\paperwidth]{sidebar}
\setlength{\beamer@headheight}{.165\paperheight}
\pgfdeclareimage[width=.13\paperwidth]{small-logo}{automation_logo}
\pgfdeclareimage[width=.23\paperwidth]{main-logo}{jjlogo}
\setbeamertemplate{sidebar left}{%
\vskip7pt
\insertverticalnavigation{\beamer@sidebarwidth}%
}

\setbeamertemplate{footline}[text line]{%
\insertshortauthor\strut\hfill\insertshorttitle\hfill\insertshortdate\hspace{1em}\insertframenumber/\inserttotalframenumber}

\addtobeamertemplate{frametitle}{}{%
\begin{pgfpicture}
    \pgf@relevantforpicturesizefalse
    \pgftransformxshift{-\Gm@lmargin}
    \pgftransformyshift{\beamer@headheight+18pt}
    \pgfpathmoveto{\pgfpoint{.15\paperwidth}{0pt}}
    \pgfpathlineto{\pgfpoint{.15\paperwidth}{-\beamer@headheight}}
    \pgfsetlinewidth{3.5pt}
    \pgfsetinnerlinewidth{1pt}
    \pgfsetinnerstrokecolor{ALUFred}
    \pgfsetcolor{white}
    \pgfusepath{stroke}
    \pgfpathmoveto{\pgfpoint{.15\paperwidth}{\paperheight}}
    \pgfpathlineto{\pgfpoint{.15\paperwidth}{-.99\paperheight}}
    \pgfsetlinewidth{0.5pt}
    \pgfsetinnerlinewidth{0pt}
    \pgfsetcolor{ALUFred}
    \pgfusepath{stroke}
    \pgftext[at=\pgfpoint{.075\paperwidth}{-.97\paperheight},center,base]{\pgfuseimage{small-logo}}
\end{pgfpicture}%
\vskip-25pt%
}

\addtobeamertemplate{title page}{%
\usebeamertemplate{title background}%
\vskip .2\paperheight%
}
{}

\newcommand\MakeBlueBackgroud{%
    \pgfpathmoveto{\pgfpointorigin}
    \pgfpathrectanglecorners{\pgfpoint{0pt}{0pt}}{\pgfpoint{\paperwidth}{-\paperheight}}
    \pgfsetfillcolor{ALUFblue}
    \pgfusepath{fill}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Title Page
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{title background}{%
\begin{pgfpicture}
    \pgf@relevantforpicturesizefalse
    \pgftransformxshift{-\Gm@lmargin}
    \pgftransformyshift{5.5pt}
    \pgfusepath{fill}
    %\MakeBlueBackgroud

    % Logo
    \pgftext[at=\pgfpoint{.009\paperwidth}{-.60\paperheight},left,base]{\pgfuseimage{main-logo}}

\end{pgfpicture}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inner Theme
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\useinnertheme{rectangles}
\setbeamertemplate{navigation symbols}{}

\setlength{\leftmargini}{.5em}
\setlength{\leftmarginii}{1.0em}
\setlength{\leftmarginiii}{1.5em}
\setlength{\leftmarginiv}{2.0em}
\setlength{\leftmarginv}{2.5em}
\setlength{\leftmarginvi}{3.0em}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Colours
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usecolortheme[named=ALUFred]{structure}
\usecolortheme{orchid}
\setbeamercolor{title page}{fg=ALUFblue, bg=ALUFwhite}
\setbeamercolor{logo}{bg=ALUFred}
\setbeamercolor{frametitle}{fg=ALUFwhite,bg=ALUFblue}
\setbeamercolor{section in sidebar}{fg=ALUFred}
\setbeamerfont{section in sidebar}{series=\bfseries}
\setbeamercolor{block title}{bg=ALUFblue!28!white,fg=ALUFblue}
\setbeamercolor{block body}{bg=ALUFred!15!white}

\newcommand\ThankYouFrame{
    \begin{frame}[plain,t]
        \begin{pgfpicture}
            \pgf@relevantforpicturesizefalse
            \pgftransformxshift{-\Gm@lmargin}
            \pgftransformyshift{5.5pt}
            \MakeBlueBackgroud
        \end{pgfpicture}
    \end{frame}
}
